package com.hongxun.design.utils.fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.hongxun.design.MyApp;
import com.hongxun.design.R;
import com.hongxun.design.bean.AddExplorationBean;
import com.hongxun.design.bean.ArticleFootBean;
import com.hongxun.design.bean.BackPhotosBean;
import com.hongxun.design.bean.BeforeExpBean;
import com.hongxun.design.bean.BeforeExpItemBean;
import com.hongxun.design.bean.BuyMenuBean;
import com.hongxun.design.bean.BuyMenuListBean;
import com.hongxun.design.bean.CarouselBean;
import com.hongxun.design.bean.CarouselItemBean;
import com.hongxun.design.bean.CategoryBean;
import com.hongxun.design.bean.CategoryItemBean;
import com.hongxun.design.bean.ChannelAListBean;
import com.hongxun.design.bean.ChannelBean;
import com.hongxun.design.bean.ChannelListBean;
import com.hongxun.design.bean.Channel_idBean;
import com.hongxun.design.bean.CheakBean;
import com.hongxun.design.bean.CodeErWeiBean;
import com.hongxun.design.bean.CodeSetBean;
import com.hongxun.design.bean.CodeSetListBean;
import com.hongxun.design.bean.CodeSetVersionBean;
import com.hongxun.design.bean.ConsumerInfo;
import com.hongxun.design.bean.EncyclopediaBean;
import com.hongxun.design.bean.EncyclopediaListBean;
import com.hongxun.design.bean.EnvInfoBean;
import com.hongxun.design.bean.ExperienceBean;
import com.hongxun.design.bean.ExperienceListBean;
import com.hongxun.design.bean.ExplorSumBean;
import com.hongxun.design.bean.Exploration;
import com.hongxun.design.bean.ExplorationList;
import com.hongxun.design.bean.HomeCarouselBean;
import com.hongxun.design.bean.LogBean;
import com.hongxun.design.bean.LogListBean;
import com.hongxun.design.bean.MaterialBean;
import com.hongxun.design.bean.MaterialInfoBean;
import com.hongxun.design.bean.MaterialListBean;
import com.hongxun.design.bean.MaterialSumBean;
import com.hongxun.design.bean.MaterialsBean;
import com.hongxun.design.bean.MyNewBean;
import com.hongxun.design.bean.NewProjectBean;
import com.hongxun.design.bean.PayBackBean;
import com.hongxun.design.bean.PhotoBean;
import com.hongxun.design.bean.PhotoGraphBean;
import com.hongxun.design.bean.PointSumBean;
import com.hongxun.design.bean.PoleSumBean;
import com.hongxun.design.bean.PoleSumListBean;
import com.hongxun.design.bean.ProjectFootBean;
import com.hongxun.design.bean.ProjectFootYearBean;
import com.hongxun.design.bean.ProjectItemBean;
import com.hongxun.design.bean.ProjectListBean;
import com.hongxun.design.bean.ProjectSumBean;
import com.hongxun.design.bean.ReconnaissanceBean;
import com.hongxun.design.bean.ScanHotBean;
import com.hongxun.design.bean.ScheduleCountBean;
import com.hongxun.design.bean.SearchAllProjectBean;
import com.hongxun.design.bean.SearchProjectBean;
import com.hongxun.design.bean.SectionBean;
import com.hongxun.design.bean.SystemVersionBean;
import com.hongxun.design.bean.TransFormerMaterialBean;
import com.hongxun.design.bean.UnitBean;
import com.hongxun.design.bean.UnitUsersBean;
import com.hongxun.design.bean.UnitsBean;
import com.hongxun.design.bean.UserBean;
import com.hongxun.design.bean.UserPointBean;
import com.hongxun.design.bean.UserPointListBean;
import com.hongxun.design.bean.WireBean;
import com.hongxun.design.bean.WireListBean;
import com.hongxun.design.bean.WxPayInfoBean;
import com.hongxun.design.bean.gpsbean.RootCode;
import com.hongxun.design.bean.photopassbean.SystemTypeBean;
import com.hongxun.design.bean.service.ProjectToIOSBean;
import com.hongxun.design.jbean.JChannelBean;
import com.hongxun.design.jbean.JCodeBean;
import com.hongxun.design.jbean.JPathBean;
import com.hongxun.design.jbean.JPhotoBean;
import com.hongxun.design.jbean.JPhotoGraphBean;
import com.hongxun.design.jbean.JReconnaissanceBean;
import com.hongxun.design.jbean.ZipPathBean;
import com.hongxun.design.jbean.jCodeSetVersionListBean;
import com.hongxun.design.jungong.model.JG_MaterialBean;
import com.hongxun.design.jungong.model.MatreialDetailSys;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.mytools.MyLog;
import com.hongxun.design.mytools.ShardPreferencesTool;
import com.hongxun.design.ui.statisticsmap.pieview.PieItemBean;
import com.hongxun.design.utils.httputil.HttpStringCodeTableUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by zerdoor_pc on 2016/5/9.
 */
public class FastJsonUtil {

    public static boolean JsonToCheck(String json) {
        // {"code":"E10002","msg":"系统异常"}
        boolean flag = false;
        if (json == null || json.length() == 0) return flag;
        try {
            if (!(json.contains("\"code\"") || json.contains("\"msg\""))) return true;
            JCodeBean bean = JSON.parseObject(json, new TypeReference<JCodeBean>() {
            });
            flag = bean.code.equals(MString.SUCCESS) || bean.msg.equals(MString.SUCCESS);
            if (bean.code.equals(MString.EXCEPTION) || bean.msg.equals(MString.EXCEPTION))
                flag = false;
            if (bean.code.equals(MString.ERRORCODE) || bean.msg.equals(MString.ERRORCODE))
                flag = false;
            if (bean.code.equals(MString.NOTLOGIN) || bean.msg.equals(MString.NOTLOGIN))
                flag = false;
            if (bean.code.equals(MString.SUCCESSED_HTTP) || bean.msg.equals(MString.SUCCESSED_HTTP))
                flag = true;
        } catch (Exception e) {
            flag = true;
        }
        return flag;
    }

    public static String JsonToCheck_String(String json) {
        if (json == null || json.length() == 0) {
            if (MyApp.isOnLine) {
                return "数据为空！";
            } else {
                return "";
            }
        }
        String s = MString.TRUE;
        try {
            JCodeBean bean = JSON.parseObject(json, new TypeReference<JCodeBean>() {
            });
//            {code: "SUCCESS",msg: "msg"}
//            {code: "错误代码",msg: "msg"}

            if (!bean.code.equals(MString.SUCCESS)) {
                s = bean.msg;
            }

        } catch (Exception e) {
            s = MString.FALSE;
        }
        return s;
    }

    /**
     * 解析二维码信息*
     */
    public static CodeErWeiBean JsonToGetCodeErWei(String json) {


        CodeErWeiBean bean = JSON.parseObject(json, new TypeReference<CodeErWeiBean>() {
        });
        return bean;
    }

    /**
     * 解析点位信息*
     */
    public static ReconnaissanceBean JsonToData(String json) {

        MyLog.L(MyApp.AppName + "jsonjson json==" + json);
        JReconnaissanceBean bean = JSON.parseObject(json, new TypeReference<JReconnaissanceBean>() {
        });
        return new ReconnaissanceBean().setReconnaissanceBean(bean);
    }

    /**
     * 解析登录信息*
     */
    public static ConsumerInfo JsonToLoginData(String json) {
        if (json.length() == 0) return null;
        ConsumerInfo bean = JSON.parseObject(json, new TypeReference<ConsumerInfo>() {
        });
        return bean;
    }

    /**
     * 解析首页轮播*
     */

    public static List<HomeCarouselBean> JsonToDataCarousel(String json) {

        CarouselBean bean = JSON.parseObject(json, new TypeReference<CarouselBean>() {
        });
        List<HomeCarouselBean> CarouselData = new ArrayList<>();
        if (bean.carousel == null || bean.carousel.size() == 0) return CarouselData;
        for (CarouselItemBean b : bean.carousel) {
            CarouselData.add(new HomeCarouselBean(b.id, b.name, b.url, b.pic));
        }
        return CarouselData;
    }

    /**
     * 解析拍照信息*
     */
    public static PhotoGraphBean JsonToData_Photos(String json) {
        MyLog.L(MyApp.AppName + "jsonjson JsonToData_Photos==" + json);
        if (json == null || json.length() == 0) return null;
        JPhotoGraphBean bean = JSON.parseObject(json, new TypeReference<JPhotoGraphBean>() {
        });
        List<PhotoBean> list = new ArrayList<>();
        for (JPhotoBean b : bean.Photos) {
            list.add(new PhotoBean(b.Type, null, b.url));
        }
        MyLog.L(MyApp.AppName + "jsonjson List<PhotoBean>==" + JSON.toJSONString(list));
        return new PhotoGraphBean(bean.Type, bean.Title, bean.Position, bean.Number, bean.NeedNumber, bean.LackNumber, list, null, null);
    }

    /**
     * 解析系统返回的照片信息*
     */
    public static BackPhotosBean JsonToData_BackPhotos(String json) {
        MyLog.L(MyApp.AppName + "jsonjson JsonToData_Photos==" + json);
        if (json == null || json.length() == 0) return null;

        return JSON.parseObject(json, new TypeReference<BackPhotosBean>() {
        });
    }

    /**
     * 解析典设版本号*
     */
    public static List<CodeSetVersionBean> JsonToData_CodeSetVersion(String json) {
        jCodeSetVersionListBean bean = JSON.parseObject(json, new TypeReference<jCodeSetVersionListBean>() {
        });
        return bean.codesetVersion;
    }

    /**
     * 解析典设列表*
     */
    public static List<CodeSetBean> JsonToData_CodeSetList(String json) {
        //{"codesetList":[ {"codeset_id":9, "name":"f", "number":"f","local_alias":"f","thumb":"upload/none.jpg","original":"upload/none.jpg","apply_range":12}]}
        //CodeSetListBean
        try {
            CodeSetListBean bean = JSON.parseObject(json, new TypeReference<CodeSetListBean>() {
            });
            return bean.getCodesetList();
        } catch (Exception e) {
            return new ArrayList<>();
        }

    }

    /**
     * 典设材料列表*
     */
    public static List<MaterialBean> JsonToData_CodeSetMaterialList(String json) {
        //{"materialList":[{"codeset_material_id":38,"codeset_id":9,"material_number":"wl0000021","erp_id":"qq","erp_code":"qq","name":"qq","big_category":1,"middle_category":2,"small_category":4,"spec":"q","unit":"q","unit_weight":1.0,"estimate_price":1.00,"thumb":"upload/none.jpg","length":1.0,"num":1,"consume_steel":1.0,"consume_concrete":1.0,"remark":"1","obj_type":0}]}
        CodeSetListBean bean = JSON.parseObject(json, new TypeReference<CodeSetListBean>() {
        });
        return bean.getMaterialList();
    }

    /**
     * 典设材料（选中）修改列表*
     */
    public static List<MaterialBean> JsonToData_CodeSetMaterial_List(String json) {
        //{"materialList":[{"codeset_material_id":38,"codeset_id":9,"material_number":"wl0000021","erp_id":"qq","erp_code":"qq","name":"qq","big_category":1,"middle_category":2,"small_category":4,"spec":"q","unit":"q","unit_weight":1.0,"estimate_price":1.00,"thumb":"upload/none.jpg","length":1.0,"num":1,"consume_steel":1.0,"consume_concrete":1.0,"remark":"1","obj_type":0}]}
        CodeSetListBean bean = JSON.parseObject(json, new TypeReference<CodeSetListBean>() {
        });
        return bean.expCodesetList;
    }

    /**
     * 材料列表*
     */
    public static List<MaterialsBean> JsonToData_MaterialList(String json) {
        //{"materialList":[{"codeset_material_id":38,"codeset_id":9,"material_number":"wl0000021","erp_id":"qq","erp_code":"qq","name":"qq","big_category":1,"middle_category":2,"small_category":4,"spec":"q","unit":"q","unit_weight":1.0,"estimate_price":1.00,"thumb":"upload/none.jpg","length":1.0,"num":1,"consume_steel":1.0,"consume_concrete":1.0,"remark":"1","obj_type":0}]}
        MaterialListBean bean = JSON.parseObject(json, new TypeReference<MaterialListBean>() {
        });
        return bean.materialList;
    }

    /**
     * 项目材料
     */
    public static List<MatreialDetailSys> getMaterialList(String json) {
        JG_MaterialBean bean = JSON.parseObject(json, new TypeReference<JG_MaterialBean>() {
        });
        return bean.materialList;
    }

    /**
     * 模块列表*
     */
    public static List<MaterialsBean> JsonToData_ModuleList(String json) {
        //{"materialList":[{"codeset_material_id":38,"codeset_id":9,"material_number":"wl0000021","erp_id":"qq","erp_code":"qq","name":"qq","big_category":1,"middle_category":2,"small_category":4,"spec":"q","unit":"q","unit_weight":1.0,"estimate_price":1.00,"thumb":"upload/none.jpg","length":1.0,"num":1,"consume_steel":1.0,"consume_concrete":1.0,"remark":"1","obj_type":0}]}
        MaterialListBean bean = JSON.parseObject(json, new TypeReference<MaterialListBean>() {
        });
        return bean.moduleList;
    }

    /**
     * (new)模块列表
     */
    public static List<MaterialsBean> JsonToData_ModuleList2(String json) {
        //{"materialList":[{"codeset_material_id":38,"codeset_id":9,"material_number":"wl0000021","erp_id":"qq","erp_code":"qq","name":"qq","big_category":1,"middle_category":2,"small_category":4,"spec":"q","unit":"q","unit_weight":1.0,"estimate_price":1.00,"thumb":"upload/none.jpg","length":1.0,"num":1,"consume_steel":1.0,"consume_concrete":1.0,"remark":"1","obj_type":0}]}
        MaterialListBean bean = JSON.parseObject(json, new TypeReference<MaterialListBean>() {
        });
        return bean.modleList;
    }

    /**
     * 解析存储的选项信息*
     */
    public static List<SystemTypeBean> JsonToData_Code(String code) {
        String json = ShardPreferencesTool.getshare(MyApp.context, code, "");
        List<SystemTypeBean> list = new ArrayList<>();
        if (FastJsonUtil.JsonToCheck(json)) {
            MyLog.L(MString.SUCCESSED + "json=" + json);
            JSONArray arr = null;
            try {
                arr = new JSONArray(json);
                for (int i = 0; i < arr.length(); i++) {
                    JSONObject temp = (JSONObject) arr.get(i);
                    String typecode = temp.getString("typecode");
                    String typename = temp.getString("typename");

                    list.add(new SystemTypeBean(typecode, typename));
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            //MyLog.L(MString.SUCCESSED + "list=" + JSON.toJSONString(list));
        }
        return list;
    }

    /**
     * 解析返回的文件路径*
     */
    public static String JsonToPath(String json) {
        return JSON.parseObject(json, new TypeReference<JPathBean>() {
        }).path;
    }

    public static String JsonToZipPathBean(String json) {
        return JSON.parseObject(json, new TypeReference<ZipPathBean>() {
        }).zipPath;
    }

    /**
     * 解析返回的文件对象*
     */
    public static JPathBean JsonToPathData(String json) {
        return JSON.parseObject(json, new TypeReference<JPathBean>() {
        });
    }

    /**
     * 解析返回的单位信息*
     */
    public static List<UnitsBean> JsonUnitData(String json, String... code) {
        List<UnitsBean> units = new ArrayList<>();
        try {


            for (int i = 0; i < code.length; i++) {
                units.add(new UnitsBean(JSON.parseObject(JSON.parseObject(json).get(code[i]).toString(), new TypeReference<List<UnitBean>>() {
                })));
            }
        } catch (Exception e) {
            MyLog.L(MString.ERROR + e.toString());
        }
        return units;
    }

    /**
     * 解析返回的人员信息*
     */
    public static List<UnitUsersBean> JsonPersonnelData(String json, String... code) {
        List<UnitUsersBean> units = new ArrayList<>();
        try {
            for (int i = 0; i < code.length; i++) {
                units.add(new UnitUsersBean(JSON.parseObject(JSON.parseObject(json).get(code[i]).toString(), new TypeReference<List<UserBean>>() {
                })));
            }
        } catch (Exception e) {
            MyLog.L(MString.ERROR + e.toString());
        }
        return units;
    }

    /**
     * 解析创建项目返回的id*
     */
    public static NewProjectBean JsonToGetId(String json) {
        return JSON.parseObject(json, new TypeReference<NewProjectBean>() {
        });
    }

    /**
     * 解析定位点上级定位点的id{"afterExp":{"exploration_id":3}}*
     */
    public static BeforeExpItemBean JsonToGetExploration_Id(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<BeforeExpBean>() {
            }).afterExp;
        } catch (Exception e) {
            return new BeforeExpItemBean();
        }
    }

    /**
     * 解析特征点(有下级)列表*
     */
    public static List<ChannelAListBean> JsonToGetChannelAList(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<ChannelBean>() {
            }).channelAList;
        } catch (Exception e) {
            return null;
        }
    }

    public static List<JChannelBean> JsonToGetRequestChannelAList(String json) {
        if (json.contains("channelAList")) {
            json = JSON.parseObject(json).getString("channelAList");
        }
        try {
            return JSON.parseObject(json, new TypeReference<List<JChannelBean>>() {
            });
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 解析特征点(无上级)列表*
     */
    public static List<ChannelListBean> JsonToGetChannelList(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<ChannelBean>() {
            }).channelList;
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 解析channel_id*
     */
    public static String JsonToGetChannel_id(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<Channel_idBean>() {
            }).channel_id;
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * 解析点位修改后的 {"exploration_id":152,"id":"10"}*
     */
    public static AddExplorationBean JsonToGetAddExploration_Id(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<AddExplorationBean>() {
            });
        } catch (Exception e) {
            return null;
        }

    }

    /**
     * 解析踏勘点列表{"explorationList":[]}*
     */
    public static List<Exploration> JsonToGetExplorationList(String json) {
        try {
            return JSON.parseObject(json, new TypeReference<ExplorationList>() {
            }).explorationList;
        } catch (Exception e) {
            return null;
        }

    }

    /**
     * 解析踏勘点信息*
     */
    public static Exploration JsonToGetExplorInfo(String json) {
        return JSON.parseObject(json, new TypeReference<Exploration>() {
        });


    }

    /**
     * 解析上联踏勘点信息*
     */
    public static Exploration JsonToGetLatsExplorInfo(String json) {
        return JSON.parseObject(JSON.parseObject(json).getString("lastExp"), new TypeReference<Exploration>() {
        });


    }

    /**
     * 解析导线信号列表{"explorationList":[]}*
     */
    public static List<SystemTypeBean> JsonToGetWireList(String json) {
        if (json.length() == 0) return new ArrayList<>();
        List<WireBean> bean = JSON.parseObject(json, new TypeReference<WireListBean>() {
        }).wireList;

        List<SystemTypeBean> list = new ArrayList<>();
        for (WireBean b : bean) {
            list.add(new SystemTypeBean(b.wire_id, b.wire_model, b.voltage_grade, JSON.toJSONString(b)));
        }
        return list;
    }

    /**
     * 解析踏勘环境信息{"envInfo":[{}]}*
     */
    public static EnvInfoBean JsonToGetEnvInfo(String json) {
        EnvInfoBean bean = JSON.parseObject(json, new TypeReference<EnvInfoBean>() {
        });
        return bean;
    }

    /**
     * 解析项目列表*
     */
    public static List<ProjectItemBean> JsonToGetProjectListBean(String json) {
        ProjectListBean bean = JSON.parseObject(json, new TypeReference<ProjectListBean>() {
        });
        return bean.projectList;
    }

    /**
     * 解析项目*
     */
    public static ProjectItemBean JsonToGetProject(String json) {
        if (json.length() == 0) return new ProjectItemBean();
        return JSON.parseObject(json, new TypeReference<ProjectItemBean>() {
        });
    }

    public static ProjectToIOSBean JsonToGetProjectToIOSBean(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectToIOSBean>() {
        });
    }

    /**
     * 解析搜索项目列表*
     */
    public static List<SearchProjectBean> JsonToGetSearchAllProject(String json) {
        SearchAllProjectBean bean = JSON.parseObject(json, new TypeReference<SearchAllProjectBean>() {
        });
        return bean.projectList;
    }

    /**
     * 解析搜索项目*
     */
    public static SearchProjectBean JsonToGetSearchProject(String json) {
        SearchProjectBean bean = JSON.parseObject(json, new TypeReference<SearchProjectBean>() {
        });
        return bean;
    }


    /**
     * 项目详情信息*
     */
    public static PointSumBean JsonToGetPointSum(String json) {
        return JSON.parseObject(json, new TypeReference<PointSumBean>() {
        });
    }

    /**
     * 台区详情信息*
     */
    public static ExplorSumBean JsonToGetExplorSum(String json) {
        return JSON.parseObject(json, new TypeReference<ExplorSumBean>() {
        });
    }

    /**
     * 项目进度统计*
     */
    public static ScheduleCountBean JsonToGetScheduleCountBean(String json) {

        return JSON.parseObject(json, new TypeReference<ScheduleCountBean>() {
        });
    }


    /**
     * 解析项目详情信息*
     */
    public static List<PoleSumBean> JsonToGetPoleSumList(String json) {
        PoleSumListBean bean = JSON.parseObject(json, new TypeReference<PoleSumListBean>() {
        });
        return bean.poleSum;
    }

    /**
     * 解析台区信息*
     */
    public static SectionBean JsonToGetSectionCorss(String json) {
        SectionBean bean = JSON.parseObject(json, new TypeReference<SectionBean>() {
        });
        return bean;
    }

    /**
     * 解析台区材料*
     */
    public static List<TransFormerMaterialBean> JsonToGetmaterialSum(String json) {

        return JSON.parseObject(json, new TypeReference<MaterialSumBean>() {
        }).materialSum;
    }

    /**
     * 解析用电户*
     */
    public static List<UserPointBean> JsonToGetUserPoint(String json) {

        return JSON.parseObject(json, new TypeReference<UserPointListBean>() {
        }).userPoint;
    }


    /**
     * 解析百科标题*
     */
    public static List<CategoryItemBean> JsonToGetCategory(String json) {

        return JSON.parseObject(json, new TypeReference<CategoryBean>() {
        }).category;
    }

    /**
     * 解析百科列表*
     */
    public static List<EncyclopediaBean> JsonToGetEncyclopediaList(String json) {

        return JSON.parseObject(json, new TypeReference<EncyclopediaListBean>() {
        }).encyclopediaList;
    }


    /**
     * 解析收藏列表*
     */
    public static List<EncyclopediaBean> JsonToGetCollectList(String json) {

        return JSON.parseObject(json, new TypeReference<EncyclopediaListBean>() {
        }).collectList;
    }

    /**
     * 解析自检结果*
     */
    public static CheakBean JsonToGetcheckProject(String json) {

        return JSON.parseObject(json, new TypeReference<CheakBean>() {
        });
    }

    /**
     * 解析自检结果*
     */
    public static ProjectSumBean JsonToGetProjectSum(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectSumBean>() {
        });
    }

    /**
     * 解析项目统计字段*
     */
    static List<SystemTypeBean> projectType_data;
    static List<SystemTypeBean> projectAttribute_data;
    static List<SystemTypeBean> projectSchedule_data;
    static List<SystemTypeBean> fundsSources_data;

    private static int[] color = {R.color.feasibilitystudy, R.color.preliminarydesign, R.color.charity, R.color.becompleted,
            R.color.colorfen, R.color.colorfentlan, R.color.coloryellow, R.color.colorsred, R.color.colorgreen,
            R.color.colorrou};

    public static List<PieItemBean> JsonToGetFieldSum(String json, int type) {
        List<PieItemBean> itemBeans = new ArrayList<>();
        com.alibaba.fastjson.JSONArray jsonArray = JSON.parseObject(json).getJSONArray("fieldSum");
        List<SystemTypeBean> data = null;
        switch (type) {
            case 1://projectType
                if (projectType_data == null)
                    projectType_data = FastJsonUtil.JsonToData_Code(HttpStringCodeTableUtil.projectType);
                data = projectType_data;
                break;
            case 2://projectAttribute
                if (projectAttribute_data == null)
                    projectAttribute_data = FastJsonUtil.JsonToData_Code(HttpStringCodeTableUtil.projectAttribute);

                data = projectAttribute_data;
                break;
            case 3://projectSchedule
                if (projectSchedule_data == null)
                    projectSchedule_data = FastJsonUtil.JsonToData_Code(HttpStringCodeTableUtil.projectSchedule);
                data = projectSchedule_data;
                break;
            case 4://fundsSources
                if (fundsSources_data == null)
                    fundsSources_data = FastJsonUtil.JsonToData_Code(HttpStringCodeTableUtil.fundsSources);

                data = fundsSources_data;
                break;

        }
        if (data == null) return itemBeans;

        int j = 0;
        for (int i = 0; i < jsonArray.size(); i++) {
            com.alibaba.fastjson.JSONObject item = jsonArray.getJSONObject(i);
            int code = item.getInteger("code");

            if (code != 0) {
                for (SystemTypeBean s : data) {
                    if (s.getTypecode().equals(code + "")) {
                        int num = item.getInteger("num");
                        itemBeans.add(new PieItemBean(s.getTypename(), num, color[j]));
                        j++;
                        break;
                    }
                }
            } else {
                int num = item.getInteger("num");
                itemBeans.add(new PieItemBean("其他", num, color[j]));
                j++;
            }
        }

        return itemBeans;
    }

    /**
     * 解析项目日志*
     */
    public static List<LogBean> JsonToGetLogList(String json) {

        return JSON.parseObject(json, new TypeReference<LogListBean>() {
        }).logList;
    }

    /**
     * 解析单个日志*
     */
    public static LogBean JsonToGetLog(String json) {

        return JSON.parseObject(json, new TypeReference<LogBean>() {
        });
    }

    /**
     * 解析项目日志填报*
     */
    public static LogListBean JsonToGetTodayProSum(String json) {

        return JSON.parseObject(json, new TypeReference<LogListBean>() {
        });
    }

    /**
     * 解析dgps*
     */
    public static RootCode getAppli(String json) {

        return JSON.parseObject(json, new TypeReference<RootCode>() {
        });
    }

    /**
     * 解析足迹*
     */
    public static List<ProjectFootYearBean> getProjectFoot_Year(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectFootBean>() {
        }).stageNumByYear;
    }

    /**
     * 解析足迹信息*
     */
    public static ProjectFootBean getProjectFoot_info(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectFootBean>() {
        });
    }

    /**
     * 解析足迹项目详情*
     */
    public static ArticleFootBean getProjectFoot_(String json) {

        return JSON.parseObject(json, new TypeReference<ArticleFootBean>() {
        });
    }


    /**
     * 解析足迹参与项目*
     */
    public static ProjectFootBean getProjectFoot_invol(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectFootBean>() {
        });
    }

    /**
     * 解析足迹完成项目*
     */
    public static ProjectFootBean getProjectFoot_finish(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectFootBean>() {
        });
    }

    /**
     * 解析足迹发布项目*
     */
    public static ProjectFootBean getProjectFoot_publish(String json) {

        return JSON.parseObject(json, new TypeReference<ProjectFootBean>() {
        });
    }


    /**
     * 解析经验*
     */
    public static List<ExperienceBean> getExperienceList(String json) {

        return JSON.parseObject(json, new TypeReference<ExperienceListBean>() {
        }).experienceList;
    }

    /**
     * 解析消息*
     */
    public static List<MyNewBean> getMyNewBeanList(String json) {

        return JSON.parseObject(json, new TypeReference<ExperienceListBean>() {
        }).sysMessList;

    }

    public static MyNewBean getMyNewBean(String json) {

        return JSON.parseObject(json, new TypeReference<MyNewBean>() {
        });
    }

    /**
     * 解析热点消息*
     */
    public static ScanHotBean getScanHotBean(String json) {

        return JSON.parseObject(json, new TypeReference<ScanHotBean>() {
        });
    }

    /**
     * 解析授权产品*
     */
    public static List<BuyMenuBean> getBuyMenuListBean(String json) {

        return JSON.parseObject(json, new TypeReference<BuyMenuListBean>() {
        }).buyMenuList;
    }

    /**
     * 解析支付信息*
     */
    public static PayBackBean getPayBackBean(String json) {

        return JSON.parseObject(json, new TypeReference<PayBackBean>() {
        });
    }

    /**
     * 解析支付信息*
     */
    public static WxPayInfoBean getWxPayInfoBean(String json) {

        return JSON.parseObject(json, new TypeReference<WxPayInfoBean>() {
        });
    }


    /**
     * 解析支付信息*
     */
    public static List<MaterialInfoBean> getMaterialInfoBean(String json) {

        return JSON.parseObject(json, new TypeReference<MaterialInfoBean>() {
        }).list;
    }


    public static SystemVersionBean JsonToSystemVersionBean(String json) {
        if (json.length() == 0) return new SystemVersionBean();
        SystemVersionBean bean = JSON.parseObject(JSON.parseObject(json).getString("sysVersion"), new TypeReference<SystemVersionBean>() {
        });
        return bean;
    }

    public static <T> T JsonToGetT(String json, TypeReference<T> type) {
        try {
            return JSON.parseObject(json, type);
        } catch (Exception e) {
            MyLog.L("解析失敗：" + e.getMessage());
            return JSON.parseObject("", type);
        }
    }

    public static String beanToJson(Object obj) {
        return JSON.toJSONString(obj);
    }

}
